﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace QLHS
{
    class HocSinh
    {
        //protected string m_maHS;
        //protected string m_maLop;
        //protected string m_maNH;
        //protected string m_hoTen;
        //protected string m_ngaySinh;
        //protected string m_phai;
        //protected string m_diaChi;
        //protected string m_dienThoai;

        public void TiepNhanHocSinh(string maHS, string maLop, string maNH, string hoTen, string ngaySinh, string phai, string diaChi, string dienThoai, string nienKhoa)
        {
            string connectionString = "Data Source=PC-200908251039;Initial Catalog=QLHS;Integrated Security=True";
            SqlConnection conn = new SqlConnection(connectionString);
            conn.Open();
            string commandText = "insert into HOCSINH " +
                                 "values (@maHS, @maLop, @maNH, @hoTen, @ngaySinh, @phai, @diaChi, @dienThoai)";
            SqlCommand comm = new SqlCommand(commandText, conn);

            comm.Parameters.Add("@maHS", SqlDbType.VarChar, 7);
            comm.Parameters["@maHS"].Value = maHS;

            comm.Parameters.Add("@maLop", SqlDbType.VarChar, 5);
            comm.Parameters["@maLop"].Value = maLop;

            comm.Parameters.Add("@maNH", SqlDbType.VarChar, 6);
            comm.Parameters["@maNH"].Value = maNH;

            comm.Parameters.Add("@hoTen", SqlDbType.NVarChar, 50);
            comm.Parameters["@hoTen"].Value = hoTen;

            comm.Parameters.Add("@ngaySinh", SqlDbType.DateTime);
            comm.Parameters["@ngaySinh"].Value = ngaySinh;

            comm.Parameters.Add("@phai", SqlDbType.NVarChar, 4);
            comm.Parameters["@phai"].Value = phai;

            comm.Parameters.Add("@diaChi", SqlDbType.NVarChar, 50);
            comm.Parameters["@diaChi"].Value = diaChi;

            comm.Parameters.Add("@dienThoai", SqlDbType.VarChar, 15);
            comm.Parameters["@dienThoai"].Value = dienThoai;

            comm.ExecuteNonQuery();
            conn.Close();
        }

    }
}
